<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/9/11
  Time: 17:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/include.jsp" %>
<html>
<head>
    <title>Title</title>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox ">
                <div class="ibox-content">

                    <div class="jqGrid_wrapper">
                        <div class="ui-jqgrid " id="gbox_table_list_2" dir="ltr">
                            <div class="ui-jqgrid-view table-responsive" role="grid" id="gview_table_list_2"
                            >


                                <form role="form" class="form-inline" style="margin-bottom: 10px" id="searchForm"
                                      method="post" action="disposeBugList.html">
                                    <div class="form-group">


                                        <input type="text" name="conditions['createName']" placeholder="录入人"
                                               value="${pages.conditions.createName}"
                                               id="createName" class="form-control">&nbsp;&nbsp;&nbsp;
                                        <select id="demandProduct" name="conditions['demandProduct']"
                                                class="form-control"
                                                required="" aria-required="true">
                                            <option value="0"
                                                    <c:if test="${pages.conditions.demandProduct == 0}">selected</c:if>>
                                                问题产品
                                            </option>
                                            <c:forEach items="${productList}" var="product">
                                                <option
                                                        <c:if test="${pages.conditions.demandProduct == product.id}">selected</c:if>
                                                        value="${product.id}">${product.product_name}</option>
                                            </c:forEach>
                                        </select>

                                    </div>
                                    &nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-primary">搜索</button>
                                    &nbsp;&nbsp;&nbsp;<button type="button" id="resetBut" class="btn btn-reset">重置
                                </button>
                                </form>


                                <div class="ui-jqgrid-bdiv">
                                    <div style="position:relative;">
                                        <div></div>
                                        <table id="cusTable"
                                               class="ui-jqgrid-btable ui-common-table table table-bordered"
                                        >
                                            <tbody>
                                            <tr role="row" style="background: #F5F5F5;">
                                                <!--<td><input th:type="checkbox" name="ches"/>-->
                                                <td>编号
                                                </td>
                                                <td>标题
                                                </td>
                                                <td>描述</td>
                                                <td>反馈人
                                                </td>
                                                <td>所属产品

                                                </td>
                                                <td>录入人
                                                </td>
                                                <td style="width: 15%">录入时间
                                                </td>

                                                <td>
                                                    状态
                                                </td>
                                                <td>操作
                                                </td>
                                            </tr>


                                            <c:forEach items="${pages.pageDatas}" var="bug">
                                                <tr role="row" id="1" tabindex="-1"
                                                    class="jqgrow ui-row-ltr" bugId="${bug.id}"
                                                    statusText="${bug.status_text}">
                                                    <td>${bug.id}
                                                    </td>
                                                    <td>${bug.title}
                                                    </td>
                                                    <td>
                                                            ${fn:length(bug.detail) > 20 ? fn:substring(bug.detail,0,20) : bug.detail}

                                                    </td>
                                                    <td>
                                                            ${bug.feedback_name}
                                                    </td>
                                                    <td>
                                                            ${bug.demand_product_name}
                                                    </td>
                                                    <td>
                                                            ${bug.create_name}
                                                    </td>
                                                    <td>
                                                            ${bug.create_time}
                                                    </td>

                                                    <td>

                                                            ${bug.status_text}

                                                    </td>

                                                    <td>
                                                        <c:if test="${bug.is_suspend !=2}">
                                                            <c:if test="${bug.status ==2}">
                                                                <a id="startbtn" bugId="${bug.id}" title="开始处理"
                                                                        departmentId="${bug.department_id}"
                                                                   class="handleicon" type="button"
                                                                        status="3">
                                                                    <i class="fa fa-check-circle"></i>
                                                                </a>


                                                                <a btnType="transfer" id="${bug.id}" status="${bug.status}" statusText ="${bug.status_text}"
                                                                   class="handleicon" type="button" title="转移"
                                                                   demandType="1"><i
                                                                        class="fa fa-refresh"></i>
                                                                </a>


                                                                <a checkBtn="bugBtn" id="${bug.id}" departmentId="${bug.department_id}"
                                                                   status="${bug.status}"
                                                                   title="驳回" class="handleicon"
                                                                   type="button" isReceive="2"><i
                                                                        class="fa fa-undo"></i>
                                                                </a>


                                                            </c:if>
                                                            <c:if test="${bug.status ==3}">
                                                                <a id="finishBtn" bugId="${bug.id}" title="处理完成"
                                                                        departmentId="${bug.department_id}"
                                                                   class="handleicon" type="button"
                                                                        status="4">
                                                                    <i class="fa fa-calendar-check-o"></i>
                                                                </a>
                                                            </c:if>

                                                            <a id="chbtn" demId="${bug.id}" demandType="2"
                                                                    isSuspend="2" title="暂停"
                                                                    suspendId="${bug.suspend_id}"
                                                               class="handleicon" type="button"><i
                                                                    class="fa fa-stop"></i>
                                                            </a>
                                                        </c:if>

                                                        <c:if test="${bug.is_suspend ==2}">
                                                            <a id="chbtn" demId="${bug.id}" demandType="2"
                                                                    title="开始" isSuspend="1"
                                                                    suspendId="${bug.suspend_id}"
                                                               class="handleicon" type="button"><i
                                                                    class="fa fa-play-circle-o"></i>
                                                            </a>
                                                        </c:if>
                                                    </td>
                                                </tr>

                                            </c:forEach>


                                            </tbody>
                                        </table>
                                        <c:if test="${pages.totalPages>1 }">
                                            <page:pager pageSize="${pages.pageSize}" currPage="${pages.currPage}"
                                                        totalRecords="${pages.totalRecords}"
                                                        url="${pageContext.request.contextPath}/disposeBugList.html?conditions['demandProduct']=${pages.conditions.demandProduct }&conditions['createName']=${pages.conditions.createName }  "/>

                                        </c:if>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!--弹框用-->

</body>

<script>

    $(function () {
        $("#resetBut").click(function () {
            $('#createName').val("");
            $('#demandProduct').val("0");
        })
    })

    var param = "";
    $(function () {

        $("[checkBtn=bugBtn]").click(function () {
            var isReceive = $(this).attr('isReceive');

            var title = "BUG审核-通过";
            var hei = "75%";
            if (2 == isReceive) {
                title = "BUG审核-驳回";
                hei = "50%";
            }

            //alert($(this).html());
            //alert($(this).attr('status'));
            //alert($(this).attr('bug_id'));
            //alert($(this).parent('tr').attr('custId'));
            index = layer.open({
                type: 2,
                title: title,
                skin: 'ilayui-layer-rm', //加上边框
                area: ['30%', hei], //宽高
                content: 'goCheckBugPage.html?id=' + $(this).attr('id') + "&status=" + $(this).attr('status')
                + "&isReceive=" + isReceive
//                end: function () {
//                    location.reload();
//                }
            });
        });


        var index = 0;

        $("[id=startbtn]").click(function () {
            var bugId = $(this).attr('bugId');
            var status = $(this).attr('status');
            var statusText = "处理中";
            var title = "确定开始处理？";
            var obj = $(this);
            layer.msg(title, {
                time: 0 //不自动关闭
                , btn: ['确定', '取消']
                , yes: function (index) {


                    var args = {
                        "bugId": bugId,
                        "status": status
                    }

                    var url = "disposeBug.html";

                    //加载进度条
                    layer.load(2, {
                        shade: [0.2, '#999999'] //0.1透明度的白色背景
                    });
                    $.post(url, args, function (data) {
                        data = jQuery.parseJSON(data);
                        //保存成功
                        if (data.code == 1) {
                            window.location.reload();
                            layer.closeAll('loading');
                        } else {
                            //失败
                            layer.alert(data.msg);
                            layer.closeAll('loading');
                        }
                    });
                    layer.close(index);

                }
            });
        });


        //转移按钮
        $("[btnType=transfer]").click(function () {
            var statusText = $(this).attr('statusText');

            var title = "BUG转移";


            //alert($(this).html());
            //alert($(this).attr('status'));
            //alert($(this).attr('demand_id'));
            //alert($(this).parent('tr').attr('custId'));
            index = layer.open({
                type: 2,
                title: title,
                skin: 'ilayui-layer-rm', //加上边框
                area: ['35%', '65%'], //宽高
                content: 'goTransferBugInDep.html?id=' + $(this).attr('id') + "&status=" + $(this).attr('status')
                + "&statusText=" + statusText,
//                end: function () {
//                    location.reload();
//                }
            });
        });


        $("[id=finishBtn]").click(function () {
            var bugId = $(this).attr('bugId');
            var status = $(this).attr('status');
            var title = "完成-BUG任务";

            var obj = $(this);
            index = layer.open({
                type: 2,
                title: title,
                skin: 'ilayui-layer-rm', //加上边框
                area: ['30%', '55%'], //宽高
                content: 'goDisposeBox.html?id=' + bugId + "&status=" + status
                + "&isReceive=1"
//                end: function () {
//                    location.reload();
//                }

            });
        });

        $("[id=chbtn]").click(function () {

            var title = "暂停-处理";

            var isSuspend = $(this).attr('isSuspend');
            if (1 == isSuspend) {
                title = "开始-处理";
            }

            //alert($(this).html());
            //alert($(this).attr('status'));
            //alert($(this).attr('bug_id'));
            //alert($(this).parent('tr').attr('custId'));
            index = layer.open({
                type: 2,
                title: title,
                skin: 'ilayui-layer-rm', //加上边框
                area: ['500px', '300px'], //宽高
                content: 'goSuspendDemand.html?&id=' + $(this).attr('demId') + "&isSuspend=" + isSuspend
                + "&suspendId=" + $(this).attr('suspendId') + "&demandType=" + $(this).attr('demandType')
//                end: function () {
//                    location.reload();
//                }
            });
        });

        //双击tr弹出页面
        $("#cusTable tr td").dblclick(function () {

            //alert($(this).html());
            //alert($(this).attr('custId'));
            //alert($(this).parent('tr').attr('custId'));
            var title = "BUG-" + $(this).parent('tr').attr('statusText');
            index = layer.open({
                type: 2,
                title: title,
                skin: 'ilayui-layer-rm', //加上边框
                area: ['90%', '90%'], //宽高
                content: 'bugDetail.html?isCheck=true&bugId=' + $(this).parent('tr').attr('bugId'),
                end: function () {
                    location.reload();
                }
            });
        });
    });

</script>
</html>
